<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		#cps{
			width: 400px;
			height: 300px;
			border:1px solid #ccc;
		}
	</style>
</head>
<body>
<div id="cps">

</div>
<script src="../js/echarts.js"></script>
<script>
  /*  var data=[[1,2],[3,4],[5,6]]
    function turnEchart(data){
        var dataX = [];
        var dataY = [];
        for(var i=0;i<data.length;i++){
            dataX.push(data[i][0]);
            dataY.push(data[i][1])
        }
        return [dataX,dataY]
    }
    function rnd(min,max){
        var tmp=min;
        if(max<min){min=max;max=tmp;}
        return Math.floor(Math.random()*(max-min+1)+min);
    }
var dataY = [1,2,3,4,5,6,7];
var dataX = [1,2,3,4,5,6,7];

var mychart = echarts.init(document.getElementById('cps'));
var option={
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'line',
            lineStyle: {
                color: '#2f2f30',
                width: 1,
                type: 'solid'
            }
        }
    },
    legend: []
	/!*{
	 orient: 'vertical',
	 right: '5%',
	 itemWidth: 10,
	 itemHeight: 10,
	 data: []
	 }*!/,
    grid: {
        left: '5%',
        right: '4%',
        bottom: '5%',
        containLabel: true
    },
    axisLine: {
        show: true,
        lineStyle: {
            color: '#2d2d2d',
            width: 1,
            type: 'solid'
        }
    },
    axisLabel: {
        show: false,
        textStyle: {
            color: '#fff'
        }
    },
    xAxis: {
        name: '时间',
        type: 'time',
        boundaryGap: true,
        data:dataX,// data.T_Time,
		//data:['2017/3/15', '2017/3/16', '2017/3/17', '2017/3/18','2017/3/19', '2017/3/20', '2017/3/21'],
        axisLine: {
            lineStyle: {
                color: '#2d2d2d'
            }
        },
        axisTick: {
            interval: 0
        },
        nameTextStyle: {
            color: '#fff'
        }
    },
    yAxis: [{
        splitLine: {
            show: true,
            lineStyle: {
                color: '#fff',
                type: 'solid',
                width: 1,
                opacity: 0.1
            }
        },
        //max:1,
        axisLine: {
            lineStyle: {
                color: '#2e2d2e'
            }
        },
        nameTextStyle: {
            color: '#fff'
        },
        axisLabel: {
            textStyle: {
                color: '#e6e6e6'
            }
        }
    }, {
        position: 'right',
        offset: 0,
        axisLine: {
            lineStyle: {
                color: '#2e2d2e'
            }
        },
        axisLabel: {
            textStyle: {
                color: '#fff'
            }
        }
    }],
	/!*toolbox: {
	 show: true,
	 left:'45%',
	 top:'0%',
	 itemGap:15,
	 feature: {
	 dataZoom: {
	 yAxisIndex: 'none'
	 },
	 restore: {}
	 }
	 },*!/
    series:[{
        type:'line',
		name:'123',
		data:dataY
		}],
};
    /!*mychart.setOption(option);*!/
    /!*setInterval(function(){
        dataX.push(rnd(0,100));
        dataY.push(rnd(0,100));
        mychart.setOption(option);
    },1000);*!/
    */
  var data = [];
  var dataX=[];
  var now = new Date();
  var oneDay =  1000;
  //var value = Math.random() * 1000;
 /* for (var i = 0; i < 1000; i++) {
      data.push(randomData());
  }
    function randomData() {
        now = new Date(+now + oneDay);
        return {
            value: [[now.getHours(),now.getMinutes(),now.getSeconds()].join(':')]
        }
    }*/

    /*setInterval(function(){
        console.log(Math.random()*9+1)
        //console.log(dataX)
	},1000)*/
    /*返回当前时间*/
  function getTime(val){
      var oData = new Date(val)
      return (oData.getFullYear()+'-'+(oData.getMonth()+1)+'-'+oData.getDate()+' '+oData.getHours()+':'+oData.getMinutes()+':'+oData.getSeconds())
  }
  //通过时间戳获取时间日期
  function getbeforetime(val){
		return (new Date(val))
  }
 //获取随机数
  function rnd(min, max) {
      return (Math.random()*(max - min) + min).toFixed(2);
  }
  /*获取七天前的时间戳*/
  var oDate = new Date();//当前时间
  var NowDatecuo = Date.parse(new Date())
  var beforDate = new Date(oDate);
  beforDate.setDate(oDate.getDate()-7);
  var beforetime=(beforDate.getFullYear()+'-'+(beforDate.getMonth()+1)+'-'+beforDate.getDate()+' '+beforDate.getHours()+':'+beforDate.getMinutes()+':'+beforDate.getSeconds());
  console.log(oDate+'的时间戳为'+NowDatecuo)//7天前的时间

  // 获取时间格式的时间戳
  var stringTime = beforetime;
  var beforedatacuo7 = Date.parse(new Date(beforetime));
  /*timestamp2 = timestamp2 / 1000;*/
  //2014-07-10 10:21:12的时间戳为：1404958872
  console.log(stringTime + "的时间戳为：" + beforedatacuo7);
  console.log(stringTime+'的日期'+(new Date(beforedatacuo7)));

  //时间戳差值
  timewtampDiff = (NowDatecuo-beforedatacuo7)/1000;
   //累加时间戳
	console.log(timewtampDiff)
  var arr = [];
  for(var i=0 ;i<1000;i++){
      var timeDate=beforedatacuo7+timewtampDiff*i;
      arr.push(getTime(timeDate))
  }
  var arrData=[];
  for(var i=0; i<1000;i++){
		arrData.push(rnd(0.8,1))
  }
  console.log(arr)
 // document.write(arr)
  document.write(arrData)
  /*function getBeforeDate(n) {
      var n = n;
      var d = new Date();
      var year = d.getFullYear();
      var mon = d.getMonth() + 1;
      var day = d.getDate();
      if(day <= n) {
          if(mon > 1) {
              mon = mon - 1;
          } else {
              year = year - 1;
              mon = 12;
          }
      }
      d.setDate(d.getDate() - n);
      year = d.getFullYear();
      mon = d.getMonth() + 1;
      day = d.getDate();
      s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
      return s;
  }
  console.log(getBeforeDate(0));//昨天的日期
  console.log(getBeforeDate(7));//前七天的日期*/




  /*console.log(getTime())
    console.log((new Date()).toLocaleTimeString().replace(/^\D*!/,''))*/

</script>
</body>

</html>